﻿<%@ Page Title="Ledger" Language="C#" MasterPageFile="~/Backoffice/BackOffice.Master"
    AutoEventWireup="true" CodeBehind="GL.aspx.cs" Inherits="TreaShares.Backoffice.User.GL" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ MasterType VirtualPath="~/Backoffice/BackOffice.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
    <script type="text/javascript">
        function showDialog(tranId) {
            $("#divId").dialog("open");
            $("#modalIframeId").attr("src", "TransactionDetails.aspx?TranId=" + tranId);
            return false;
        }

        $(document).ready(function () {
            $("#divId").dialog({
                autoOpen: false,
                modal: true,
                height: 530,
                width: 500
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table border="0" cellpadding="2" cellspacing="2">
        <tr>
            <td>
                Period End Date
            </td>
            <td>
                <asp:TextBox ID="txtSummaryFrom" runat="server" ClientIDMode="Static" CssClass="datepicker"></asp:TextBox>
            </td>
            <td align="right">
                <asp:Button ID="btnTransactionSummary" runat="server" Text="Run" CssClass="button"
                    OnClick="btnTransactionSummary_Click" />
            </td>
        </tr>
    </table>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
        GridLines="None" ShowGroupPanel="True" ShowFooter="True" CellSpacing="0" DataSourceID="ObjectDataSource1">
        <ClientSettings AllowDragToGroup="True" ReorderColumnsOnClient="True">
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <GroupingSettings RetainGroupFootersVisibility="true" ShowUnGroupButton="true" />
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" ShowGroupFooter="true"
            DataSourceID="ObjectDataSource1">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <GroupByExpressions>
                <telerik:GridGroupByExpression>
                    <SelectFields>
                        <telerik:GridGroupByField FieldName="Id" HeaderText="Entry Id" />
                    </SelectFields>
                    <GroupByFields>
                        <telerik:GridGroupByField FieldName="Id" />
                    </GroupByFields>
                </telerik:GridGroupByExpression>
            </GroupByExpressions>
            <NoRecordsTemplate>
                No GL records
            </NoRecordsTemplate>
            <Columns>
                <telerik:GridDateTimeColumn DataField="TransactionDate" DataType="System.DateTime"
                    FilterControlAltText="Filter TransactionDate column" HeaderText="Transaction Date"
                    SortExpression="TransactionDate" UniqueName="TransactionDate" DataFormatString="{0:d}">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="ValueDate" DataType="System.DateTime" FilterControlAltText="Filter ValueDate column"
                    HeaderText="Value Date" SortExpression="ValueDate" UniqueName="ValueDate" DataFormatString="{0:d}">
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="ChartAccount" FilterControlAltText="Filter ChartAccount column"
                    HeaderText="Chart Account" SortExpression="ChartAccount" UniqueName="ChartAccount">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Currency" FilterControlAltText="Filter Currency column"
                    HeaderText="Currency" SortExpression="Currency" UniqueName="Currency">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="DebtCredit" FilterControlAltText="Filter DebtCredit column"
                    HeaderText="Debt/Credit" SortExpression="DebtCredit" UniqueName="DebtCredit">
                </telerik:GridBoundColumn>
                <telerik:GridNumericColumn DataField="ValueDR" DataType="System.Double" FilterControlAltText="Filter Value column"
                    HeaderText="Debit Amount" SortExpression="ValueDR" UniqueName="ValueDR" DataFormatString="{0:###,###.00}"
                    Aggregate="Sum">
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="ValueCR" DataType="System.Double" FilterControlAltText="Filter Value column"
                    HeaderText="Credit Amount" SortExpression="ValueCR" UniqueName="ValueCR" DataFormatString="{0:###,###.00}"
                    Aggregate="Sum">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="EventDescription" FilterControlAltText="Filter EventDescription column"
                    HeaderText="Event Description" SortExpression="EventDescription" UniqueName="EventDescription">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="Trade ID">
                    <ItemTemplate>
                        <a href="#" onclick="return showDialog(<%# Eval("ID") %>)" style="color:Blue">
                            <%# Eval("ID")  %></a>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
               <%-- <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column"
                    HeaderText="ID" SortExpression="ID" UniqueName="ID">
                </telerik:GridBoundColumn>--%>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetLedger" TypeName="TreaShares.Backoffice.Controlers.GLManager">
        <SelectParameters>
            <asp:CookieParameter CookieName="OrganisationId" Name="ClientId" Type="String" />
            <asp:ControlParameter ControlID="txtSummaryFrom" Name="periodEndDate" PropertyName="Text"
                Type="DateTime" />
        </SelectParameters>
    </asp:ObjectDataSource>
    
    <div id="divId" title="Transaction details">
        <iframe id="modalIframeId" width="100%" height="100%" marginwidth="0" marginheight="0"
            frameborder="0" scrolling="auto" title="Dialog Title">Your browser does not suppr</iframe>
    </div>
</asp:Content>
